<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>应付结清明细</title>
        <% include("/common/common_css_js.html"){} %>
    </head>
    <body>
        <div style="padding-bottom: 5px;">
            <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">
                <span class="separator"></span>
                <span>单号：</span><input id="keyBillId" name="keyBillId" emptyText="请输入单号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="单号不能为空" />
                <span class="separator"></span>
                <span>单号类型:</span><input id="keyBillTypeId" name="keyBillTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择单号类型"/>
                <span class="separator"></span>
                <span>结费类型:</span><input id="keyBillPayClearedTypeId" name="keyBillPayClearedTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择结费类型"/>
                <span class="separator"></span>
                <span>结费日期：</span>
                <input id="keyClearedStartDate" name="keyClearedStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>
                --
                <input id="keyClearedEndDate" name="keyClearedEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>

                <div style="margin-top: 5px"></div>

                <% if(so.hasPermission("payClearedList:query")){%>
                    <a class="mini-button" iconCls="icon-search" onclick="searchBill()">查询</a>
                <% } %>

                <% if(so.hasPermission("payClearedList:queryCndClear")){%>
                    <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
                <% } %>

                <span class="separator"></span>
                <% if(so.hasPermission("payClearedList:download")){%>
                    <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="结费信息表"/>
                <% } %>

            </div>
        </div>

        <div class = "mini-fit">
            <div id="datagrid1" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/finance_manage/pay/queryPayClearedList" idField="id"
                 showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
                 multiSelect = "true" allowResize="true"
                 showGroupsSummary="true" showSummaryRow="true" summaryPosition="bottom"
                 allowSortColumn = "true"
                 sortField="createTime"
                 sortOrder="desc"
                 ondrawsummarycell="summaryRight"
            >
                <div property="columns">
                    <div field="billId" width="140" headerAlign="center" align="left" allowSort="true"  renderer="showMasterBillRender">单号</div>
                    <div field="billTypeId" width="140" headerAlign="center" align="left" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">单号类型</div>
                    <div field="billPayClearedTypeId" width="140" headerAlign="center" align="left" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">费用类型</div>
                    <div field="billPayClearedAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">金额</div>
                    <div field="createTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">创建时间</div>
                    <div field="createUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">创建用户</div>
                </div>
            </div>

        </div>

        <script type="text/javascript">
            mini.parse();

            let keyBillId = mini.get("keyBillId");
            let keyBillTypeId = mini.get("keyBillTypeId");
            let keyBillPayClearedTypeId = mini.get("keyBillPayClearedTypeId");

            let grid = mini.get("datagrid1");

            $(function () {
                // 单号类型
                let keyBillTypeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_BILL_TYPE");
                keyBillTypeId.load(keyBillTypeIdJsonData);

                // 总运费结费状态
                let keyBillPayClearedTypeIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_BILL_PAY_CLEARED_TYPE");
                keyBillPayClearedTypeId.load(keyBillPayClearedTypeIdJsonData);

                // 加载列表数据
                grid.load();
            });

            /**
             * 清空查询条件
             */
            function clearSearch(){
                let form = new mini.Form("#queryForm");
                form.clear();
            }

            /**
             * 根据查询条件查询分单
             */
            function searchBill(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);
                grid.load(data);
            }

            function summaryRight(e){
                e.cellStyle="text-align:right;color:red;font-size:18px;font-weight:bold";
            }

            /**
             * 371,370,分单,分单
             372,370,航空主单,航空主单
             373,370,汽运主单,汽运主单
             */


            let billType ={native:371,air:372,auto:373};

            // 展示主单号时显示其超链接
            function showMasterBillRender(e){
                // renderer="showMasterBillRender"

                let billId = e.value;
                let billTypeId = e.record.billTypeId;
                let htmlStr = "<a href='javascript:void(0);' onclick='showViewMasterBill(\""+ billId +"\"," + billTypeId + ")'>" + billId + "</a>";

                return htmlStr;
            }

            function showViewMasterBill(billId,billTypeId){
                let tabUrl= "";
                let tabTitle = "";
                if(billTypeId==billType.air){
                    tabUrl="${base}/pages/master_bill_manage/flight/showUpdateMasterBill?opType=view&id=" + billId;
                    tabTitle = "航空主单查看";
                }
                else if ((billTypeId==billType.auto)){
                    tabUrl="${base}/pages/master_bill_manage/auto/showUpdateMasterBill?opType=view&id=" + billId;
                    tabTitle = "汽运主单查看";
                }
                else{
                    tabUrl="${base}/pages/native_bill_manage/showUpdateBill?opType=view&id=" + billId;
                    tabTitle = "分单查看";
                }
                parent.window.addTabToMainPage(tabTitle,tabTitle,tabUrl);
            }

        </script>
    </body>
</html>